import { FC } from "react";
import { useParams } from 'react-router-dom';
import { linkGet } from "../../service/resouce";
import { AxiosError } from "axios";
import { message } from "antd";

const Skip: FC = () => {
    const param = useParams()
    const code = param?.code
    if (code) {
        //如果存在，就获取长链并跳转
        linkGet(code).then(res => {
            const link = res.data
            //如果存在链接，直接跳转链接
            if (link) { window.location.href = link }
        }).catch((error: AxiosError<string>) => {
            message.error({ content: error.response?.data })
        })
    }
    return <span></span>
}
export default Skip